#include <fastcommon/logger.h>
#include <fastdfs/fdfs_client.h>
#include <iostream>

int main(int argc, char* argv[])
{
    if(argc != 2)
    {
        std::cout << "Usage: " << argv[0] << " file_id" << std::endl;
        return 1;
    }

    //1,初始化日志输出模块
    g_log_context.log_level = LOG_ERR;
    log_init();

    //2, 初始化客户端全局配置 (1, 从配置文件中初始化， 2， 从缓冲区进行初始化)
    int ret = fdfs_client_init("./client.conf");
    if(ret != 0)
    {
        std::cout << "fdfs_client_init failed, ret: " << STRERROR(ret) << std::endl;
    }

    auto tracker_server = tracker_get_connection();
    if(tracker_server == nullptr)
    {
        std::cout << "tracker_get_connection failed" << std::endl;
    }

    //3,文件删除
    ret = storage_delete_file1(tracker_server, nullptr, argv[1]);
    if(ret != 0)
    {
        std::cout << "fdfs_delete_file failed, ret: " << STRERROR(ret) << std::endl;
    }

    std::cout << "文件删除成功" << argv[1] << std::endl;
    tracker_close_connection(tracker_server);
    fdfs_client_destroy();
    return 0;
}


